import Layout from '@/views/layout/Layout'
import HelloWorld from '@/views/HelloWorld'
import HelloWorld1 from '@/views/HelloWorld1'
import HelloWorld2 from '@/views/HelloWorld2'
import Login from '@/views/login/Login'
import Error401 from '@/views/error/Error401'
import Error404 from '@/views/error/Error404'
// import Error500 from '@/views/error/Error500'

/**
 * 标签页导航的路由需定义到 '/' 路由的children节点中
 * 独立页面需定义在'/' 路由的外部
 * name:             标签页标题的备选方案、未命名组件name的备选方案、命名路由
 * meta.title:       标签页标题的首选方案
 * meta.closable:    标识该标签页是否可关闭，默认true-可关闭
 * meta.cachable:    标识该标签页是否可被keep-alive缓存，默认true-缓存
 */
const errorRoute = [
  {
    path: 'error/401',
    name: 'error401',
    component: Error401
  },
  {
    path: 'error/404/',
    name: 'error404',
    component: Error404
  },
  {
    path: 'error/500',
    name: 'error500',
    component: () => import('@/views/error/Error500.vue')
  }
]

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        name: 'dashboard',
        component: HelloWorld,
        meta: {
          closable: false
        }
      },
      ...errorRoute,
      {
        path: 'h1',
        name: 'test1',
        component: HelloWorld1
      },
      {
        path: 'h2',
        name: 'test2',
        component: HelloWorld2,
        meta: {
          cachable: false
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }
]

export default routes
